<template>
  <SysDialog draggable :title="dialog.title" :visible="dialog.visible" :width="dialog.width" :height="dialog.height"
    @onClose="onClose" @onConfirm="confirm">
    <template v-slot:content>
      <!-- 内容组件 -->
      <el-form :model="dialogModel" ref="addTaskForm" :rules="rules" label-width="120px" size="default">
        <el-form-item prop="taskBaseline" label="基线名称">
          <el-input v-model="dialogModel.taskBaseline"></el-input>
        </el-form-item>
      </el-form>
    </template>
  </SysDialog>
</template>

<script setup lang='ts'>
import { ref } from "vue";
import SysDialog from "@/components/SysDialog.vue";
import { ElForm } from "element-plus";
import useDialog from "@/hooks/useDialog";
import useInstance from "@/hooks/useInstance";
import { EditType, Title } from "@/type/BaseEnum";
import BaseLineModel from "@/composables/02Review/01ProjectMan/BaseLineModel";
const addTaskForm = ref<InstanceType<typeof ElForm>>();
const { dialogModel, rules } = BaseLineModel();
const emit = defineEmits(["save"]);
// 使用
const { dialog, onClose, onShow } = useDialog();
const { global, proxy } = useInstance();
// 父级数据

const confirm = () => {
  addTaskForm.value?.validate((isOk) => {
    if (isOk) {
      emit("save", dialogModel);
      onClose();  
    }
  });
};
const show = (type: string, row?: any) => {
  // console.log("show");
  dialog.width = 650;
  dialog.height = 50;
  dialog.title = EditType.ADD ? Title.ADD : Title.EDIT;
  onShow();
  global.$resetForm(addTaskForm.value, dialogModel);
  dialogModel.taskId = row;
  if (type === EditType.EDIT) {
    global.$objCopy(row, dialogModel);
  }
};
defineExpose({
  show,
});
</script>
<style scoped lang='scss'></style>